package com.indexingsystem.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.indexingsystem.boss.admin.mapper.RoleGroupsMapper;
import com.indexingsystem.boss.common.PagedResult;
import com.indexingsystem.boss.entity.RoleGroups;
import com.indexingsystem.boss.utils.BeanUtils;
import com.indexingsystem.system.service.IRoleGroupsService;

@Service
public class RoleGroupsServiceImpl implements IRoleGroupsService {

	@Resource
	private RoleGroupsMapper roleGroupsMapper;

	@Override
	public int deleteByPrimaryKey(String roleGroupId) {
		return roleGroupsMapper.deleteByPrimaryKey(roleGroupId);
	}

	@Override
	public int insertSelective(RoleGroups record) {
		return roleGroupsMapper.insertSelective(record);
	}

	@Override
	public RoleGroups selectByPrimaryKey(String roleGroupId) {
		return roleGroupsMapper.selectByPrimaryKey(roleGroupId);
	}

	@Override
	public int updateByPrimaryKeySelective(RoleGroups record) {
		return roleGroupsMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 批量删除角色组信息.
	 * 
	 * @param roleGroupIdList
	 * @return
	 */
	@Override
	public int deleteRoleGroupsByIdBatch(List<String> roleGroupIdList) {
		return roleGroupsMapper.deleteRoleGroupsByIdBatch(roleGroupIdList);
	}

	/**
	 * 分页查询显示列表.
	 */
	@Override
	public PagedResult<RoleGroups> queryListByPage(String queryCriteria,Integer pageNo, Integer pageSize) {
		pageNo = pageNo == null ? 1 : pageNo;
		pageSize = pageSize == null ? 10 : pageSize;
		// startPage是告诉拦截器说我要开始分页了。分页参数是这两个。
		PageHelper.startPage(pageNo, pageSize);
		return BeanUtils.toPagedResult(roleGroupsMapper.queryListByPage(queryCriteria));
	}

	/**
	 * 获取角色组总记录数.
	 */
	@Override
	public Integer getRoleGroupsCount(String queryCriteria) {
		return roleGroupsMapper.getRoleGroupsCount(queryCriteria);
	}

	@Override
	public RoleGroups selectByRoleGroupName(String roleGroupName) {
		return roleGroupsMapper.selectByRoleGroupName(roleGroupName);
	}

	/**roleGroupsMapper
	 * 获取角色组列表.
	 */
	@Override
	public List<RoleGroups> queryRoleGroupsInfoList() {
		return roleGroupsMapper.queryRoleGroupsInfoList();
	}
}